home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news!enno
- From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
- Newsgroups: comp.lang.c++
- Subject: Re: Operator Overloading
- Date: 05 Jan 1996 20:18:09 GMT
- Organization: Fachbereich Informatik, TH Darmstadt
- Distribution: world
- Message-ID: <ENNO.96Jan5211810@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- References: <4chdhb$g64@news.cs.hope.edu>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- In-reply-to: vnopstal@cs.hope.edu's message of 4 Jan 1996 20:32:43 GMT
-
- In article <4chdhb$g64@news.cs.hope.edu> vnopstal@cs.hope.edu (Michael Van Opstall) writes:
-
- A couple of questions on operator overloading:
-
- 1. If you overload ==, do you have to overload != as well?
-
- In general no --- However some luxery doesn't hurt.
- If 'a!=b' holds whenever 'a==b' is false and vice versa one could
- implement 'a!=b' in terms of the equality-operator:
-
- template<class S,class T>
- inline bool operator != (const S& x,const T& y) { return !(x==y); }
-
- This guarantees that either 'a==b' or 'a!=b' holds but not both at
- the same time.
-
- 2. What is the accepted method for overloading >> and <<? The way I do it
- is not very cool and not slick at all. Should I be including streams and doing
- stream manipulation? That makes sense.
-
- ???
-
- Enno
-